﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using FeiraGame_XNA.src.core.gameobjects;

namespace FeiraGame_XNA.src.core.manager
{
    /// <summary>
    ///Classe que gerencia todos os objectos na tela fazendo seu update e seu draw respectivamente .Class for manage all objects ( mob , tower ,object interface , any ) and do respectives updates and draws.
    /// </summary>
    public static class GameManager
    {
        
        #region Lists
        public static List<Mob> MobList = new List<Mob>();
        public static List<Tower> TowerList = new List<Tower>();
        #endregion 

        /// <summary>
        /// Basic Initialize
        /// </summary>
        #region Initialize
        public static void Initialize()
        {

        }
        #endregion

        /// <summary>
        /// Função que adiciona todos os objetos nas listas.
        /// </summary>
        #region Update All Objects in Lists
        public static void Update()
        {
            foreach (Mob mob in MobList)
            {
                mob.Update();
            }

            foreach (Tower tower in TowerList)
            {
                tower.Update();
            }
        }
        #endregion

        /// <summary>
        /// Função que desenha todos os objetos na tela que estão dentro das listas
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="spriteBatch"></param>
        #region Draw All Objects on Lists
        public static void Draw(GameTime gameTime,SpriteBatch spriteBatch)
        {
            foreach (Mob mob in MobList)
            {
                mob.Draw(gameTime, spriteBatch, true);
            }

            foreach (Tower tower in TowerList)
            {
                tower.Draw(gameTime, spriteBatch, true);
            }
        }
        #endregion

        //Conjunto de Funções que são autoexplicativas e que adicionam ou removem objetos.
        #region Add And Remove Objects
        public static void AddMob(Mob mob)
        {
            MobList.Add(mob);
        }

        public static void AddTower(Tower tower)
        {
            TowerList.Add(tower);
        }

        public static void RemoveMob(Mob mob)
        {
            MobList.Remove(mob);
        }
        public static void RemoveMob(int ID)
        {
            MobList.RemoveAt(ID);
        }

        public static void RemoveTower(Tower tower)
        {
            TowerList.Remove(tower);
        }
        public static void RemoveTower(int ID)
        {
            TowerList.RemoveAt(ID);
        }
        #endregion
    }
}
